package com.ruoyi.merchant.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.merchant.domain.PlatformOption;
import com.ruoyi.merchant.service.IPlatformOptionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【GPS平台选择】Controller
 * 
 * @author ruoyi
 * @date 2024-09-14
 */
@RestController
@RequestMapping("/platform/gps")
public class PlatformOptionController extends BaseController
{
    @Autowired
    private IPlatformOptionService platformOptionService;

    /**
     * 查询【GPS平台选择】列表
     */
    @PreAuthorize("@ss.hasPermi('system:gps:list')")
    @GetMapping("/list")
    public TableDataInfo list(PlatformOption platformOption)
    {
        startPage();
        platformOption.setUserId(SecurityUtils.getUserId());
        List<PlatformOption> list = platformOptionService.selectPlatformOptionList(platformOption);
        return getDataTable(list);
    }

    /**
     * 导出【GPS平台选择】列表
     */
    @PreAuthorize("@ss.hasPermi('system:gps:export')")
    @Log(title = "【GPS平台选择】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlatformOption platformOption)
    {
        List<PlatformOption> list = platformOptionService.selectPlatformOptionList(platformOption);
        ExcelUtil<PlatformOption> util = new ExcelUtil<PlatformOption>(PlatformOption.class);
        util.exportExcel(response, list, "【GPS平台选择】数据");
    }

    /**
     * 获取【GPS平台选择】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:gps:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(platformOptionService.selectPlatformOptionById(id));
    }

    /**
     * 新增【GPS平台选择】
     */
    @PreAuthorize("@ss.hasPermi('system:gps:add')")
    @Log(title = "【GPS平台选择】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlatformOption platformOption)
    {
        return toAjax(platformOptionService.insertPlatformOption(platformOption));
    }

    /**
     * 修改【GPS平台选择】
     */
    @PreAuthorize("@ss.hasPermi('system:gps:edit')")
    @Log(title = "【GPS平台选择】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlatformOption platformOption)
    {
        return toAjax(platformOptionService.updatePlatformOption(platformOption));
    }

    /**
     * 删除【GPS平台选择】
     */
    @PreAuthorize("@ss.hasPermi('system:gps:remove')")
    @Log(title = "【GPS平台选择】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(platformOptionService.deletePlatformOptionByIds(ids));
    }
}
